/**
 * 
 */
package com.lehecai.core.api.user;

import com.lehecai.core.api.AbstractApiResultBean;
import com.lehecai.core.lottery.RemitChannel;
import com.lehecai.core.lottery.WithdrawType;
import com.lehecai.core.util.CoreDateUtils;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

/**
 * @author qatang
 * 提款日志扩展表，用于某些第三方支付提款时需要提供对应方案号和充值流水号等需求
 */
public class WithdrawLogExt extends AbstractApiResultBean {
	public static final String QUERY_WITHDRAW_ID = "withdraw_id";
	public static final String QUERY_ORDER_ID = "order_id";
	public static final String QUERY_PLAN_ID = "plan_id";
	public static final String QUERY_RECHARGE_ID = "recharge_id";
	public static final String QUERY_PAY_NO = "pay_no";
	public static final String QUERY_WITHDRAW_TYPE = "withdraw_type";
	public static final String QUERY_REMIT_CHANNEL = "remit_channel";
	public static final String QUERY_TIMELINE = "timeline";

	public static final String ORDER_WITHDRAW_ID = "withdraw_id";
	public static final String ORDER_TIMELINE = "timeline";

	private String withdrawId;			//流水ID
	private String orderId;			//订单ID
	private String planId;			//方案ID
	private String rechargeId;			//充值流水ID
	private String payNo;	//第三方支付流水
    private WithdrawType withdrawType;
    private RemitChannel remitChannel;
    private Date timeline;
	


	public static WithdrawLogExt convertFromJSONObject(JSONObject object) {
		if (object == null) {
			return null;
		}
		WithdrawLogExt log = new WithdrawLogExt();

		log.withdrawId = getString(object, "withdraw_id");
		log.orderId = getString(object, "order_id");
		log.planId = getString(object, "plan_id");
		log.rechargeId = getString(object, "recharge_id");
		log.payNo = getString(object, "pay_no");

        int withdrawTypeValue = getInt(object, "withdraw_type");
		log.withdrawType = WithdrawType.getItem(withdrawTypeValue);

        int remitChannelValue = getInt(object, "remit_channel");
        log.remitChannel = RemitChannel.getItem(remitChannelValue);

		log.timeline = CoreDateUtils.parseDate(getString(object, "timeline"), CoreDateUtils.DATETIME);
		return log;
	}
	
	public static List<WithdrawLogExt> convertFromJSONArray(JSONArray array) {
		if (array == null) {
			return null;
		}
		List<WithdrawLogExt> list = new ArrayList<WithdrawLogExt>();
		for (Iterator<?> iterator = array.iterator(); iterator.hasNext();) {
			JSONObject object = (JSONObject) iterator.next();
			list.add(convertFromJSONObject(object));
		}
		return list;
	}

    public String getWithdrawId() {
        return withdrawId;
    }

    public void setWithdrawId(String withdrawId) {
        this.withdrawId = withdrawId;
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public String getPlanId() {
        return planId;
    }

    public void setPlanId(String planId) {
        this.planId = planId;
    }

    public String getRechargeId() {
        return rechargeId;
    }

    public void setRechargeId(String rechargeId) {
        this.rechargeId = rechargeId;
    }

    public String getPayNo() {
        return payNo;
    }

    public void setPayNo(String payNo) {
        this.payNo = payNo;
    }

    public WithdrawType getWithdrawType() {
        return withdrawType;
    }

    public void setWithdrawType(WithdrawType withdrawType) {
        this.withdrawType = withdrawType;
    }

    public RemitChannel getRemitChannel() {
        return remitChannel;
    }

    public void setRemitChannel(RemitChannel remitChannel) {
        this.remitChannel = remitChannel;
    }

    public Date getTimeline() {
        return timeline;
    }

    public void setTimeline(Date timeline) {
        this.timeline = timeline;
    }
}
